Learn R Programming

bnlearn (version 0.4)

model string tools: Build a model string from a Bayesian network and vice versa

Description

Build a model string from a Bayesian network and vice versa.

Usage

modelstring(x)
  model2network(string, debug = FALSE)

## S3 method for class 'bn': as.character(x, ...) ## S3 method for class 'character': as.bn(x, debug = FALSE)

Arguments

x
an object of class "bn".
string
a character string describing the Bayesian network.
debug
a boolean value. If TRUE a lot of debugging output is printed; otherwise the function is completely silent.
...
extra arguments from the generic method (currently ignored).

Value

  • model2network and as.bn.character return an object of class bn; modelstring and as.character.bn return a character string.

Details

The strings returned by modelstring have the same format as the ones returned by the modelstring function in package deal; network structures may be easily exported to and imported from that package (via the model2network function).

Examples

Run this code
data(learning.test)
res = set.arc(gs(learning.test), "A", "B")

modelstring(res)
# [1] "[F][C][A][B|A][D|A:C][E|B:F]"
res2 = model2network(modelstring(res))
compare(res, res2)
# [1] TRUE

Run the code above in your browser using DataLab